package poker;

import java.util.ArrayList;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-05-25
 * Time:21:52
 */

public class Test {
    public static ArrayList<Poker> buyPoker(ArrayList<Poker>pokers){
        String[] suit={"♦","♣","♥","♠"};
        for (int i = 1; i < 14; i++) {
            for (int j = 0; j < 4; j++) {
                pokers.add(new Poker(suit[j],i));
            }
        }
        pokers.add(new Poker("大王",0));
        pokers.add(new Poker("小王",0));
        return pokers;
    }

    public static ArrayList<Poker> washPoker(ArrayList<Poker>pokers){
        for (int i = pokers.size() - 1; i > 0; i--) {
            Random random=new Random();
            int j=random.nextInt(i);
            swap(pokers,i,j);
        }
        return pokers;
    }
    public static void swap(ArrayList<Poker>pokers,int i,int j){
        Poker tmp=pokers.get(i);
        pokers.set(i, pokers.get(j));
        pokers.set(j,tmp);
    }

    public static void getPoker(ArrayList<ArrayList<Poker>> players,ArrayList<Poker> pokers){
        players.add(new ArrayList<Poker>());
        players.add(new ArrayList<Poker>());
        players.add(new ArrayList<Poker>());
        int i=0;
        while(i<pokers.size()){
            for (int j = 0; j < 3; j++) {
                (players.get(j)).add(pokers.get(i));
                i++;
            }
        }
    }
    public static void main(String[] args) {
        ArrayList<Poker> pokers=new ArrayList<Poker>();
        System.out.println("买扑克");
        buyPoker(pokers);
        System.out.println(pokers);
        System.out.println("洗牌");
        washPoker(pokers);
        System.out.println(pokers);
        ArrayList<ArrayList<Poker>> players =new ArrayList<>(3);
        System.out.println("发牌");
        getPoker(players,pokers);
        System.out.println(players.get(0));
        System.out.println(players.get(1));
        System.out.println(players.get(2));
    }

}
